package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.view.BusinessDataVO;
import com.sky.view.DishOverViewVO;
import com.sky.view.OrderOverViewVO;
import com.sky.view.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Slf4j
@RestController
@RequestMapping("/admin/workspace")
public class WorkSpaceController {

    @Autowired
    private WorkspaceService workspaceService;

    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData(){
        log.info("查询今日数据");
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(LocalDate.now(),LocalDate.now());
        return Result.success(businessDataVO);
    }

    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> orderOverView(){
        log.info("查询订单管理数据");
        OrderOverViewVO orderOverView = workspaceService.getOrderOverView();
        return Result.success(orderOverView);
    }

    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> dishOverView(){
        log.info("查询菜品总览");
        DishOverViewVO dishOverView = workspaceService.getDishOverView();
        return Result.success(dishOverView);
    }

    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> setmealOverView(){
        log.info("查询套餐总览");
        SetmealOverViewVO setmealOverView = workspaceService.getSetmealOverView();
        return Result.success(setmealOverView);
    }
}
